<?php
namespace common\modules\social\models;

use Yii;
use yii\behaviors\TimestampBehavior;
use common\modules\social\models\query\FriendshipQuery;

/**
 * This is the model class for table "{{%friendship}}".
 *
 * @property integer $id
 * @property integer $follow_who
 * @property integer $who_follow
 * @property integer $created_at
 *
 * @author Xuegui Yuan <yuanxuegui@163.com>
 */
class Friendship extends \yii\db\ActiveRecord
{

    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%friendship}}';
    }

    /**
     * @inheritdoc
     */
    public function behaviors()
    {
        return [
            [
                'class' => TimestampBehavior::className(),
                'updatedAtAttribute' => false
            ]
        ];
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [
                [
                    'who_follow',
                    'follow_who'
                ],
                'required'
            ],
            [
                [
                    'id',
                    'follow_who',
                    'who_follow'
                ],
                'integer'
            ]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('common', 'ID'),
            'follow_who' => Yii::t('common', 'Follow Who'),
            'who_follow' => Yii::t('common', 'Who Follow'),
            'created_at' => Yii::t('common', 'Created At')
        ];
    }

    /**
     * @inheritdoc
     *
     * @return \common\modules\social\models\query\FollowQuery the active query used by this AR class.
     */
    public static function find()
    {
        return new FriendshipQuery(get_called_class());
    }
}
